
cmake_minimum_required(VERSION 3.10.2)


# 定义一个函数，用于根据 ABI 设置输出目录
#function(set_output_directory)
#    # 使用 ANDROID_ABI 变量来获取当前目标的 ABI
#    if(ANDROID)
#        set(abi ${ANDROID_ABI})
#    else()
#        # 如果没有定义 ANDROID_ABI，使用默认值
#        set(abi "unknown")
#    endif()
#
#    # 设置动态库的输出目录
#    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/jniLibs/${abi} PARENT_SCOPE)
#endfunction()
#
## 调用函数来设置输出目录
#set_output_directory()
include_directories(libyuv/include)
add_subdirectory(libyuv ./build)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
        mylibyuv

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        libyuv_jni.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        mylibyuv

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib}
        yuv)
